import "./index.css"
import React, { Component } from 'react'

export default class List extends Component {
  render() {
    const { users, isFirst, isLoading, err } = this.props

    return (
      <div className=''>
        {/* <div className='card'>
          <a href='https://github.com/reactjs' target="_blank" rel="noreferrer">
            <img src='https://avatars.githubusercontent.com/u/6412038?v=3' alt='head_portrait' style={{ width: "100px" }} />
          </a>
          <p className='card-text'>reactjs</p>
        </div> */}
        {
          isFirst ? <h2>欢迎使用，请输入关键字，随后点击搜索</h2> :
          isLoading ? <h2>加载中...</h2> :
          err ? <h2 style={{color: "red"}}>{err.message}</h2> :
          users.map((user) => {
            return (
              <div className='card' key={user.id}>
                <a href={user.url} target="_blank" rel="noreferrer">
                  <img src={user.cover} alt={user.title} style={{ width: "100px" }} />
                </a>
                <p className='card-text'>{user.title}</p>
              </div>
            )
          })
        }
      </div>
    )
  }
}
